//
//  FXComposeMenuButton.swift
//  微博(Swift)
//
//  Created by V on 16/1/5.
//  Copyright © 2016年 V. All rights reserved.
//

import UIKit

class FXComposeMenuButton: UIButton {
    
    // 如果不重写 点击按钮的 高亮状态的方法，会出现这个问题： 当点击按钮的时候，button会先变动向右变动 frame ，然后再进行放大
    override var highlighted: Bool {
        set{
            
        }
        get{
            return false
        }
    }
    
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        imageView?.frame.origin.x = 0
        imageView?.frame.origin.y = 0
        imageView?.frame.size = CGSize(width: frame.width, height: frame.width)
        
        titleLabel?.frame.origin.x = 0
        titleLabel?.frame.origin.y = frame.width
        titleLabel?.frame.size = CGSize(width: frame.width, height: frame.height - frame.width)
        
    }
    
    
    private func setupUI(){
        titleLabel?.font = UIFont.systemFontOfSize(16)
        setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        titleLabel?.textAlignment = .Center
        // 更改 imageView 的contenttype
        imageView?.contentMode = .Center
    }

}
